﻿using System;
using System.Collections.Generic;
using System.Linq;

using Moe.ECamel.Common.Entities;

namespace Moe.ECamel.Server.BL
{
	public class PaymentBL : ECamelBL
	{
		public PaymentBL(ECamelDataContext dataContext) 
			: base(dataContext)
		{
		}

		public void AddPayments(IEnumerable<Payment> payments)
		{
			this.dataContext.Payments.InsertAllOnSubmit(payments);
		}

		public IList<Payment> GetCustomerPayments(int customerId)
		{
			return (from p in dataContext.Payments
			        where p.CustomerId == customerId
					orderby p.PayedOn descending
					select p).ToList();
		}
	}
}
